// stores/userinfo.js 定义一些全局参数变量
import { defineStore } from "pinia";
export const useUserStore = defineStore("userinfo", {
  state: () => {
    return {
      userinfo: {}, //用户信息
    };
  },
  getters: {
    //员工工号
    userid: (state) =>
      state.userinfo.job_number || state.userinfo.userid || "10958253",
    //员工名
    name: (state) => state.userinfo.name || "XXX",
  },
  actions: {
    setUserInfo(userinfo = null) {
      this.userinfo = userinfo;
    },
  },
  persist: {
    storage: sessionStorage,
  },
});
